#ifndef __INCrngLibh__
#define __INCrngLibh__

#include <stddef.h>

#ifndef BOOL
#define BOOL int
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct		/* RING - ring buffer */
    {
    size_t pToBuf;      /* offset from start of buffer where to write next */
    size_t pFromBuf;	/* offset from start of buffer where to read next */
    size_t bufSize;	    /* size of ring in bytes */
    char * buf;		    /* pointer to start of buffer */
    } RING;

/* END_HIDDEN */

typedef RING *RING_ID;

/* function declarations */

extern BOOL 	ringIsEmpty (RING_ID ringId);
extern BOOL 	ringIsFull (RING_ID ringId);
extern RING_ID 	ringCreate (size_t nbytes);
extern size_t 	ringBufGet (RING_ID ringId, char *buffer, size_t maxbytes);
extern size_t 	ringBufPut (RING_ID ringId, char *buffer, size_t nbytes);
extern size_t 	ringFreeBytes (RING_ID ringId);
extern size_t 	ringNBytes (RING_ID ringId);
extern void 	ringDelete (RING_ID ringId);
extern void 	ringFlush (RING_ID ringId);
extern void 	ringMoveAhead (RING_ID ringId, size_t n);
extern void 	ringPutAhead (RING_ID ringId, char byte, size_t offset);
extern size_t   ringElemGet (RING_ID ringId, char *  pCh);
extern size_t   ringElemPut (RING_ID ringId, char pCh);
#ifdef __cplusplus
}
#endif

#endif /* __INCrngLibh */
